package com.SouthernWall_404.age_tool.Client.Render;

import com.SouthernWall_404.age_tool.common.world.Entity.MimicBlockEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.world.level.block.state.BlockState;

public class MimicBlockRenderer implements BlockEntityRenderer<MimicBlockEntity> {
    public MimicBlockRenderer(BlockEntityRendererProvider.Context context) {
    }
    
    @Override
    public void render(MimicBlockEntity blockEntity, float partialTick, PoseStack poseStack,
                       MultiBufferSource bufferSource, int packedLight, int packedOverlay) {
        
        BlockState stateToRender = blockEntity.mimicBlock;
        if (stateToRender == null) return;
        
        // 获取方块渲染器
        BlockRenderDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
        
        // 渲染方块
        dispatcher.renderSingleBlock(stateToRender, poseStack, bufferSource, packedLight, packedOverlay);
    }
}